import { observable, action,computed } from 'mobx';
import _ from "lodash";

// 资源项
class Index {
    @observable token = "";
    news = observable([]);
    activities = observable([]);
    pages=observable({
        tab:0,
        pageSize:2,
        page:1
    })

    @computed
    set(){
        this.news.push({title:'test'})
    }

    @action
    getList(){
        if(this.news.length<1){
            _.api('consult.all').then((res)=>{
                this.news.length = 0;
                this.activities.length = 0;
                Array.prototype.push.apply(this.news,res.news);
                Array.prototype.push.apply(this.activities,res.activities);
            })
        }
    }

    @action
    setPage(o){
        Object.assign(this.pages,o)
    }
}

export default new Index();
